<body>
<pre>
<?php

try {
	$user = "user";
	$pass = "pass";
    $db = new PDO('mysql:host=localhost;dbname=prova', $user, $pass);
    $db->setAttribute( PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION );
    $rs = $db->query('SELECT * FROM UTENTE',PDO::FETCH_ASSOC);
    echo "FETCH_ASSOC\n\n";
    foreach($rs as $row) {
    	print_r($row);
        echo "</br>";
    }
    echo "FETCH_OBJ\n\n";
	$rs = $db->query('SELECT * FROM UTENTE',PDO::FETCH_OBJ);
    foreach($rs as $row) {
    	print_r($row);
        echo "</br>";
    }
    
    
    $db = null;
} catch (PDOException $e) {
    print "Error!: " . $e->getMessage() . "<br/>";
    die();
}


function arrayToObject($d) {
		if (is_array($d)) {
			/*
			* Return array converted to object
			* Using __FUNCTION__ (Magic constant)
			* for recursive call
			*/
			return (object) array_map(__FUNCTION__, $d);
		}
		else {
			// Return object
			return $d;
		}
}
?>
</pre>
</body>